package com.solcoo.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.stereotype.Repository;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.solcoo.pojo.ZheKou;

@Repository
public class ZheKouDao {

	@Resource
	private SqlMapClient sqlMapClient;
	
    // 根据商户ID获取折扣的list
    public List<ZheKou> queryListByShid(int shanghuid) throws SQLException {
        return sqlMapClient.queryForList("selectDiscount", shanghuid);
    }

    public boolean add(ZheKou zhekou) throws SQLException {
        sqlMapClient.insert("insertDiscount",zhekou);
        return true;
    }

    // 根据经验值来获取折扣
    public List<ZheKou> queryObjectByJyz(int shanghuid, double jingyanz) throws SQLException {
    	Map<String, Object> param = new HashMap<String, Object>();
    	param.put("shanghuid", shanghuid);
    	param.put("jingyanz", jingyanz);
        return sqlMapClient.queryForList("selectDiscountByEmp", param);
    }

	// 根据商户ID和经验值获取该经验值对应下个等级的折扣
	public ZheKou selectNextLevelObject(int shanghuid, double jingyanz) throws SQLException {
    	Map<String, Object> param = new HashMap<String, Object>();
    	param.put("shanghuid", shanghuid);
    	param.put("jingyanz", jingyanz);
        return (ZheKou)sqlMapClient.queryForObject("selectNextLevelByEmp", param);
	}
}
